home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VRECOLR.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  4KB  |  110 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. DOSSEG
  14. .MODEL MEDIUM,BASIC
  15.  
  16. .DATA
  17.         ;external data so all video routines can access
  18.         EXTRN   B$DVIDEOSEG:WORD
  19.         EXTRN   B$DVIDEOPORT:WORD
  20.         EXTRN   B$DVIDEOINSTL:BYTE
  21.  
  22. .CODE
  23. INCLUDE  NOWAIT.INC
  24. EXTRN   Get_Adapter:FAR
  25.  
  26. ;============================================================================
  27. ; DECLARE SUB RECOLOR (BYVAL OrigColor%, BYVAL NewColor%)
  28. ; CALL RECOLOR( OrigColor%, NewColor%)
  29. ; Purposes: Change one specific color to another without upsetting the display
  30. ; or using palette registers (which couldn't be restored easily using an EGA)
  31. ;
  32. ; Color is written as BackGround * 16 + ForeGround color
  33. ;
  34. ; Sensitive to all video modes (i.e. no snow on CGA's)
  35. ; Assumes: Display width is 80 * 25, 80 * 43 or 80 * 50
  36. ;============================================================================
  37.  
  38. EVEN
  39. RECOLOR PROC FAR BASIC USES SI DS, OLD_COLOR:WORD, NEW_COLOR:WORD
  40.  
  41.     Assume DS:@data
  42.  
  43.         Cmp     B$DVIDEOINSTL,1   ; See if we have done this before
  44.         JE      Didit             ; yep, so skip ahead
  45.         Call    Get_Adapter       ; call routine to find display type
  46.  
  47. Didit:
  48.                                   ; determine video page size, do it the hard
  49.                                   ; way (row times column) because of error
  50.                                   ; in certain HERC clones
  51.         Xor     AX,AX             ; clear AX
  52.         Mov     ES,AX             ; set ES to BIOS ram
  53.         Xor     BH,BH             ; clear high byte
  54.         Mov     BL,Byte Ptr ES:[0484h]  ; read ROW from BIOS ram
  55.         Or      BL,BL             ; is ROW 0? (i.e. is this CGA, HERC or MONO?)
  56.         JNZ     @f                ; nope, it is a EGA, MCGA or VGA
  57.         Mov     BL,24             ; set default ROW to 24
  58. @@:
  59.         Inc     BL                ; remove 0 bias of ROW
  60.         Mov     AX,ES:[044Ah]     ; read COLUMN from BIOS ram
  61.         Mul     BX                ; multiply ROW times COLUMN
  62.         Mov     CX,AX             ; store Page_Size in bytes in CX
  63.         Mov     DX,B$DVIDEOPORT   ; get retrace port info
  64.                                   ; DX = 0 if MONO or EGA/VGA, else = CGA
  65.                                   ; retrace port
  66.         CLD                       ; clear direction flag
  67.         Mov     SI,1              ; start counting at attribute
  68.         Mov     AX,OLD_COLOR      ; NOTE BYVAL in use
  69.         Mov     BX,NEW_COLOR      ; NOTE BYVAL in use
  70.         Mov     BH,AL             ; Get NEW_COLOR in BL
  71.                                   ; Put OLD_COLOR in BH
  72.         Mov     AX,B$DVIDEOSEG    ; get default video segment
  73.         Mov     DS,AX             ; store in DS
  74.         
  75. Main:
  76.         OR      DX,DX             ; is this a snowy CGA?
  77.         JZ      Mono              ; DX = 0 so it is not
  78.  
  79. CGA:
  80.         Cli
  81.         Wait_CGA_Retrace          ; wait for CGA retrace MACRO
  82.         Mov     AL, Byte Ptr DS:[SI]  ; read current attribute
  83.         Cmp     AL,BH             ; does it equal OLD_COLOR?
  84.         JNE     CGA1              ; nope skip ahead
  85.         Sti                       ; allow interrupts for a second
  86.         Cli                       ; clear interrupts again
  87.         Wait_CGA_Retrace          ; wait for CGA retrace MACRO
  88.         Mov     Byte Ptr DS:[SI],BL  ; write NEW_COLOR
  89.  
  90. CGA1:
  91.         Sti                        ; allow interrupts again
  92.         Add     SI,2               ; skip to next attribute
  93.         Loop    CGA                ; do Loop again
  94.         Jmp     short Finis        ; changed all the bytes
  95.  
  96. Mono:
  97.         Mov     AL, Byte Ptr DS:[SI]  ; read attribute
  98.         Cmp     AL,BH              ; does it equal OLD_COLOR?
  99.         jnz     Mono1              ; nope so skip ahead
  100.         Mov     Byte Ptr DS:[SI],BL   ; write NEW_COLOR
  101.  
  102. Mono1:
  103.         Add     SI,2               ; skip to next attribute
  104.         Loop    Mono               ; do loop again until all bytes changed
  105.  
  106. Finis:
  107.         Ret
  108. RECOLOR        ENDP
  109. END
  110.